package com.foreknow.springboot.controller;

import com.foreknow.springboot.po.Business;
import com.foreknow.springboot.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


//@Controller
@RestController
@RequestMapping("/BusinessController")
public class BusinessController {
    @Autowired
    private BusinessService businessService;

    /**
     * 可以使用Business对象来接受前台的请求参数（无需再写resuest.getParameter）
     * @param business
     * @return
     * @ResponseBody 以json格式返回给前台
     * @RestController这是 Springboot中提供好的注意（相当于 @Controller + @ResponseBody）
     *
     * 面试题：使用Springboot中提供好的@RestController注解有什么好处
     *
     */
    @RequestMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessByOrderTypeId(Business business){
        return businessService.listBusinessByOrderTypeId(business.getOrderTypeId());
    }

    /**
     *根据商家编号查询商家信息
     * @param business
     * @return
     * @ResponseBody 以json格式返回给前台
     */
//    @ResponseBody
    @RequestMapping("/getBusinessId")
    public Business getBusinessId(Business business){
        return businessService.getBusinessId(business.getBusinessId());
    }

}
